package state;

/**
 * @author mubei
 * @date 2021/11/20
 * @description
 */
public class TestState {

    public static void main(String[] args) throws Exception {
        Thread thread = new Thread(()->{
            for (int i = 0; i < 5; i++) {
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
            System.out.println("////");
        },"vip");

        //观测线程的状态
        Thread.State state = thread.getState();
        System.out.println(state);

        thread.start();
        state = thread.getState();
        System.out.println(state);

        //
        while(state != Thread.State.TERMINATED){
           thread.sleep(100);
           state = thread.getState();
            System.out.println(state);
        }
    }


}
